package com.chilly.lambda;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * Created by Chilly Cui on 2020/11/19.
 */
public class Main {
    public static void main(String[] args) {
        List<String> list = Arrays.asList("peter", "jack");

        //老版本的Java中是如何排列字符串的
        Collections.sort(list, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o2.compareTo(o1);
            }
        });

        //Lambda表达式(Lambda expressions)
        Collections.sort(list, (String a, String b) -> {
            return a.compareTo(b);
        });
        Collections.sort(list, (String a, String b) -> b.compareTo(a));
        list.sort((a, b) -> b.compareTo(a));

    }
}
